import { ExpandOf } from "../../../../../Decorator/Decorator";
import { Unit } from "../../../../Model/Share/Module/Unit/Unit";
import { UnitComponent } from "../../../../Model/Share/Module/Unit/UnitComponent";

/**
 * 使用 Expand 扩展方法
 * 
 * 必须作出以下申明，才能调用对象的扩展方法
 */
declare module "../../../../Model/Share/Module/Unit/UnitComponent" {

    interface UnitComponent {
        Add(unit: Unit): void;
        Get(id: number): Unit;
        Remove(id: number): void;
    }

}

@ExpandOf(UnitComponent)
export class UnitComponentSystem {

    private static Add(self: UnitComponent, unit: Unit): void {

    }

    private static Get(self: UnitComponent, id: number): Unit {
        let unit = self.GetChild<Unit>(id);
        return unit;
    }

    private static Remove(self: UnitComponent, id: number): void {
        let unit = self.GetChild<Unit>(id);
        unit?.Dispose();
    }

}